<template>
	<div id="app">
		<!-- 如果返回的数据为空就展示这里面的为空的数据 -->
		<div class="no_content" v-if="is_null">
			<icon name="no_content" scale="15"></icon>
		</div>
		
		<div v-if="is_content">
			<v-card class="mx-auto" width="100%" style="margin-top: 1%;" outlined v-for="(house,i) in house_list"
				:key="i">
				<v-card-actions>
					<div style="color: #747577;width: 100%;"><span style="float: left;">看房时间：{{house.see_date}} </span>
					<span style="float: right;color:#FF5252;" v-if="house.status=='WAIT_PAYMENT'">待付款</span>
					<span style="float: right;color:#FF5252;" v-if="house.status=='WAIT_COMMENT'">待评价</span>
					<span style="float: right;color:#FF5252;" v-if="house.status=='COMPLETE'">已完成</span>
					<span style="float: right;color:#FF5252;" v-if="house.status=='CANCELED'">已取消</span>
					<span style="float: right;color:#FF5252;" v-if="house.status=='PAID'">已支付</span></div>
				</v-card-actions>
				<v-divider></v-divider>
				<v-list-item three-line @click="goHouseDel(house.house_id)">
					<v-list-item-avatar tile size="100" width="130" class="image_border_list"><img :src="house.house.index_image_url" alt="未加载" />
					</v-list-item-avatar>
					<v-list-item-content>
						<v-list-item-title class="headline mb-1"><span style="font-size: 16px;">{{house.house.title}}</span></v-list-item-title>
						<v-list-item-subtitle><span>{{house.house.area_name}}</span>&nbsp;&nbsp;|&nbsp;&nbsp;<span>{{house.house.lease_type}}</span>&nbsp;&nbsp;|&nbsp;&nbsp;<span>{{house.house.acreage}}m²</span>&nbsp;&nbsp;|&nbsp;&nbsp;<span>{{house.house.renovation}}</span></v-list-item-subtitle>
						<div class="overline" style="color:#FF5252">{{house.house.month_price}}元/月</div>
					</v-list-item-content>
			
				</v-list-item>
				<v-divider></v-divider>
				<!-- 如果刚订单的状态为已支付，则修改房屋状态判断是否已经出租 -->
				<v-card-actions style="float: right; height: 4vh;">
					<div style="margin-right: 5% ;">
						<v-btn outlined style="color:red;height: inherit;" @click="goComment(house.order_id)">评价</v-btn>
					</div>
				</v-card-actions>
				<div class="clearfloat"></div>
			</v-card>
			<div style="padding-top: 1vh;"></div>
		</div>
	</div>

</template>

<script>
	import axios from "axios";
	export default {
		name: "AppraiseOrder",
		data() {
			return {
				house_list:[],
				is_content:false,
				is_null:false
			}
		},
		methods: {
			// pay_monay() {
			// 	this.$router.push({
			// 		path: "/mine/house_order/pay_moneny"
			// 	})
			// },
			goHouseDel(house_id) {
				this.$router.push({
					name: "房屋详情",
					query:{house_id:house_id}
				});
			},
			goComment(order_id){
				this.$router.push({
					name: "评论订单",
					params:{order_id:order_id}
				});
			}
		},
		mounted() {
			let _this = this;
			axios
				.get("/api/v1.0/order/get_house_order",{
					params:{
						status:"wait_comment"
					}
				})
				.then(function(response) {
					if (response.data.errno == '0') {
						_this.house_list = response.data.data;
						console.log(response.data.data)
						// 判断是否已经认证
						if (_this.house_list.length == 0) {
							_this.is_null = true;
						} else {
							_this.is_content = true;
						}
					} else if (response.data.errno == '4101') {
						// 未登跳转到登录页面
						setTimeout(function() {
							_this.$router.replace({
								path: "/login"
							});
						}, 1000);
					}else{
						console.log(response.data.data)
					}
				})
				.catch(function() {
					_this.message = "连接服务器失败！";
				});
		}
		// ,
		// beforeRouteLeave(to, from, next) {
		// 	if(to.path=="/main/mine" || to.path=="/housing_detail")
		// 	{
		// 		from.meta.keepAlive = false;
		// 	}
		// 	next();
		// }
		// ,
		// beforeRouteLeave(to, from, next) {
		// 	if (to.path == "/mine/house_order") {
		// 		to.meta.keepAlive = true;
		// 	} else {
		// 		to.meta.keepAlive = false;
		// 	}
		// 	next();
		// }
	}
	
	
</script>

<style scoped>
</style>
